sqlcmd -S localhost\SQLEXPRESS -q

"USE [master]
GO
CREATE DATABASE [database_name] ON 
( FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\<database name>.mdf'  ),
( FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\<database name>.ldf'  )
 FOR ATTACH ;
GO
select name from sys.databases
go"


"USE master;
GO
EXEC sp_detach_db @dbname = N'AdventureWorks';
GO"